function! Reverse(string) abort
    return a:string->split('.\zs')->reverse()->join('')
endfunction

function! IsPalindrome(string) abort
    return a:string ==# a:string->Reverse()
endfunction

function! PalindromizeEnding(string) abort
    for index in range(a:string->strchars())
        if a:string->strcharpart(index)->IsPalindrome()
            return a:string->strcharpart(0, index)->Reverse()
        endif
    endfor
    return a:string->Reverse()
endfunction

function! Palindromize(string) abort
    return a:string . a:string->PalindromizeEnding()
endfunction
